package com.hecate;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * @author 黄星星
 * @date 2020-04-14
 */
public class MyThreadThree {

    public static void main(String[] args) throws Exception {

        ImplCallable implCallable = new ImplCallable();
        FutureTask futureTask = new FutureTask(implCallable);
        new Thread(futureTask).start();
        new Thread(futureTask).start();
        System.out.println(Thread.currentThread().getName() + "------------" + futureTask.get());
    }
}

class ImplCallable implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        int result = 0;
        for (int i = 0; i < 10; i++) {
            result += i;
        }
        return result;
    }
}